<script>
import { getAccessToken, getMobile, setDeviceInfo } from '@/utils/storage'

export default {
  async onLaunch() {
    // 获取字典项
    getAccessToken() && await this.$store.dispatch('dict/loadDictDatas')

    const { screenHeight, screenWidth, statusBarHeight, platform, safeAreaInsets } = uni.getSystemInfoSync()
    // 默认导航栏高度：安卓 50px，iOS 40px
    let navbarHeight = platform === 'android' ? 50 : 40
    if (uni.canIUse('getMenuButtonBoundingClientRect')) {
      // 胶囊位置信息
      const rect = uni.getMenuButtonBoundingClientRect()
      // 导航栏高度
      navbarHeight = (rect.top - statusBarHeight) * 2 + rect.height
    } else {
      wx.showToast({
        title: '您的微信版本过低，界面可能会显示不正常',
        icon: 'none',
        duration: 2000,
      })
    }

    setDeviceInfo({
      screenHeight,
      screenWidth,
      statusBarHeight,
      navbarHeight,
      safeAreaInsets,
    })
  },
}
</script>

<style lang="scss">
/*每个页面公共css */
page {
  color: #333;
  font-size: 14px;
}
</style>
